//
//  e7singleton.h
//  e7engine
//
//  Created by cc on 12-6-6.
//  Copyright (c) 2012年 cc. All rights reserved.
//

#ifndef e7engine_e7singleton_h
#define e7engine_e7singleton_h

#include "e7utilitydefine.h"

class CE7Percent ;
namespace e7engine {
    template <class T> class CE7Singleton
    {
    private:
        CE7Singleton(const CE7Singleton<T>&) ;
        CE7Singleton& operator = (const CE7Singleton<T>&) ;
    protected:
        static T* s_pSingleton ;
    public:
        CE7Singleton(void)
        {
            __ASSERT(0 == s_pSingleton) ;
            s_pSingleton = static_cast<T*>(this) ;
        }
        ~CE7Singleton(void)
        {
            __ASSERT(0 != s_pSingleton) ;
            s_pSingleton = 0 ;
        }
        static T& Instance(void)
        {
            __ASSERT(0 != s_pSingleton) ;
            return (*s_pSingleton) ;
        }
        static T* Pointer(void)
        {
            __ASSERT(0 != s_pSingleton) ;
            return s_pSingleton ;
        }
    } ;
    template<class T> T* CE7Singleton<T>::s_pSingleton = 0 ;
}

#endif



























